package com.abc.tomcat;

import com.abc.servnet.NettyRequest;
import com.abc.servnet.NettyResponse;
import com.abc.servnet.Servnet;

/**
 * tomcat  中默认servnet
 * 当用户访问的servnet 不存在时，会自动范根该默认的Servnet
 */
public class DefaultServnet extends Servnet {
    @Override
    public void doGet(NettyRequest request, NettyResponse response) throws Exception {
        //从请求中获取用户所要访问的servnet的名称
        //例如用户提交的行为请求：
        //http://localhost:9999/otherservlet/abc/def?abc=abc
        String servnetName = request.getUri().split("/")[1];
        String content = "404 - no this servnet:"+servnetName;
        response.write(content);
    }

    @Override
    public void doPost(NettyRequest request, NettyResponse response) throws Exception {
        doGet(request, response);
    }
}
